class MyThread extends Thread{
    @Override
    public void run() {
        while (true){
            System.out.println("hello world!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class ThreadDemo1 {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        myThread.start();
        while (true){
            System.out.println("main!");
            Thread.sleep(1000);
        }
    }
}
